package com.maduar.mybatis.demo.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.ZoneAvoidanceRule;
import feign.Contract;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * Description:
 *
 * @author maduar maduar@163.com
 * @date 2021-04-12 00:09
 */
@Configuration
public class AutoBeanConfig {

    @Bean(name = "SnowFlake")
    public SnowFlakeConfig getSnowFlakeInstance() {
        return new SnowFlakeConfig(11L, 12L);
    }

    @Bean("factoryAppointmentProperties")
    @ConditionalOnProperty(value = "factory.appointment.third", havingValue = "third")
    @ConfigurationProperties(prefix = "factory.appointment")
    public Properties factoryAppointmentProperties() {
        return new Properties();
    }

    @Bean
    public Contract feignContract() {
        return new Contract.Default();
    }

    @Bean
    public IRule feignRule() {
        return new ZoneAvoidanceRule();
    }
}
